/*
 * 公共类库，所有方法都为静态方法
 */

Ext.define('EF.lib.Common', {
	singleton: true,
	
	//全局调用服务器端函数，调用服务器端方法的唯一入口
	CallServerFun:function(className, methodName, params, successFun, FailureFun)
	{
		if( className == '' )
		{
			Ext.Msg.alert('参数错误', '请指定要调用的类名');
		}
		else if( methodName == '')
		{
			Ext.Msg.alert('参数错误', '请指定要调用的方法名');
		}
		else
		{
			Ext.Ajax.request({
		    	url: 'server/AppEntry.ashx?class=' + className + '&method=' + methodName,
		    	
		    	method: 'POST',
		    	
		    	jsonData: params,
		    	
		    	success: function(response){
		    		var responseObject = Ext.decode(response.responseText);
		
		    		if( responseObject.success == true )
		    		{
		    			if(successFun)
		        			successFun(responseObject.data);
		        		else
		        			Ext.Msg.alert('', '操作成功！');
		    		}
		    		else
		    		{
		    			if(FailureFun)
		    				FailureFun(responseObject.data);
		    			else
		    				Ext.Msg.alert('错误','发生错误');
		    		}
		    	},
		    	
			    failure: function(response){
			    	Ext.Msg.alert('错误','发生错误');
		    		//var responseObject = Ext.decode(response.responseText);
		    		//Ext.Msg.alert(responseObject.data)
		    	}
			});
		}
	}
});